# CMake 最低版本号要求
cmake_minimum_required (VERSION 3.20)

if(POLICY CMP0042)
    cmake_policy(SET CMP0042 NEW)  # CMake 3.0+ (2.8.12): MacOS "@rpath" in target's install name
endif()

# 项目工程名
project (ch01)

# 下面两个用法的结果是相同的,set会修改SRC_LIST的值，aux_source_directory 会增加
set(SRC_Ex1_2 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_2.cpp)
set(SRC_Ex1_3 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_3.cpp)
set(SRC_Ex1_4 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_4.cpp)
set(SRC_Ex1_5 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_5.cpp)
set(SRC_Ex1_6 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_6.cpp)
#set(SRC_Ex1_7 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_7.cpp)
set(SRC_Ex1_8 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_8.cpp)
set(SRC_Ex1_9 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_9.cpp)
set(SRC_Ex1_10 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_10.cpp)
set(SRC_Ex1_11 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_11.cpp)
set(SRC_Ex1_12 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_12.cpp)
set(SRC_Ex1_13_9 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_13_9.cpp)
set(SRC_Ex1_13_10 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_13_10.cpp)
set(SRC_Ex1_13_11 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_13_11.cpp)
set(SRC_Ex1_16 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_16.cpp)
set(SRC_Ex1_18 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_18.cpp)
set(SRC_Ex1_19 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_19.cpp)
set(SRC_Ex1_20 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_20.cpp)
set(SRC_Ex1_21 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_21.cpp)
set(SRC_Ex1_22 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_22.cpp)
set(SRC_Ex1_23 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_23.cpp)
set(SRC_Ex1_25 ${CMAKE_CURRENT_SOURCE_DIR}/exercise1_25.cpp)
#aux_source_directory(. SRC_LIST)


# 指定可执行文件存放目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

# 构建可执行程序
ADD_EXECUTABLE(exercise1_2 ${SRC_Ex1_2})
ADD_EXECUTABLE(exercise1_3 ${SRC_Ex1_3})
ADD_EXECUTABLE(exercise1_4 ${SRC_Ex1_4})
ADD_EXECUTABLE(exercise1_5 ${SRC_Ex1_5})
ADD_EXECUTABLE(exercise1_6 ${SRC_Ex1_6})
#ADD_EXECUTABLE(exercise1_7 ${SRC_Ex1_7})
ADD_EXECUTABLE(exercise1_8 ${SRC_Ex1_8})
ADD_EXECUTABLE(exercise1_9 ${SRC_Ex1_9})
ADD_EXECUTABLE(exercise1_10 ${SRC_Ex1_10})
ADD_EXECUTABLE(exercise1_11 ${SRC_Ex1_11})
ADD_EXECUTABLE(exercise1_12 ${SRC_Ex1_12})
ADD_EXECUTABLE(exercise1_13_9 ${SRC_Ex1_13_9})
ADD_EXECUTABLE(exercise1_13_10 ${SRC_Ex1_13_10})
ADD_EXECUTABLE(exercise1_13_11 ${SRC_Ex1_13_11})
ADD_EXECUTABLE(exercise1_16 ${SRC_Ex1_16})
ADD_EXECUTABLE(exercise1_18 ${SRC_Ex1_18})
ADD_EXECUTABLE(exercise1_19 ${SRC_Ex1_19})
ADD_EXECUTABLE(exercise1_20 ${SRC_Ex1_20})
ADD_EXECUTABLE(exercise1_21 ${SRC_Ex1_21})
ADD_EXECUTABLE(exercise1_22 ${SRC_Ex1_22})
ADD_EXECUTABLE(exercise1_23 ${SRC_Ex1_23})
ADD_EXECUTABLE(exercise1_25 ${SRC_Ex1_25})

#如何编译和使用
# mkdir -p D4Books/T1PrimerCpp/ch01/build
# cd D4Books/T1PrimerCpp/ch01/build
# cmake ..
# make or cmake --build .

#exercise1_2
# bin/exercise1_2
# echo $?

#exercise1_3
# bin/exercise1_3

#exercise1_23
#bin/exercise1_23 < ../assets/bookStoreInfile


#the same as above ...